package com.battle.service.controller.web;

import com.battle.pojo.param.trainingGroup.*;
import com.battle.pojo.vo.trainingGroup.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/小组训练
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/trainingGroup/web")
public class TrainingGroupWebController {

    private final TrainingGroupService service;

    public TrainingGroupWebController(TrainingGroupService service) {
        this.service = service;
    }


    /**
     * 创建小组训练
     *
     * @param param
     * @return
     */
    @PostMapping("/createTrainingGroup")
    public ApiResult createTrainingGroup(@RequestBody @Valid CreateTrainingGroupParam param) {
        service.createTrainingGroup(param);
        return ApiResult.ok();
    }


    /**
     * 修改小组训练
     *
     * @param param
     */
    @PutMapping("/editTrainingGroup")
    public ApiResult editTrainingGroup(@RequestBody @Valid EditTrainingGroupParam param) {
        service.editTrainingGroup(param);
        return ApiResult.ok();
    }

    /**
     * 移除小组训练
     *
     * @param id
     */
    @DeleteMapping("/removeTrainingGroup")
    public ApiResult removeTrainingGroup(@RequestParam("id") Long id) {
        service.removeTrainingGroup(id);
        return ApiResult.ok();
    }

    /**
     * 获取小组训练详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getTrainingGroup")
    public ApiResult<GetTrainingGroupVo> getTrainingGroup(@RequestParam("id") Long id) {
        GetTrainingGroupVo vo = service.getTrainingGroup(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取小组训练列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getTrainingGroupList")
    public ApiResult<PageResult<GetTrainingGroupListVo>> getTrainingGroupList(@RequestBody GetTrainingGroupListParam param) {
        PageResult<GetTrainingGroupListVo> result = service.getTrainingGroupList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取小组训练下拉列表
     *
     * @return
     */
    @PostMapping("/getTrainingGroupDownList")
    public ApiResult<List<GetTrainingGroupDownListVo>> getTrainingGroupDownList(@RequestBody(required = false) @Valid GetTrainingGroupDownListParam param) {
        List<GetTrainingGroupDownListVo> list = service.getTrainingGroupDownList(param);
        return ApiResult.ok(list);
    }


}

